import { defineWrappedResponseHandler } from "#server/utils/handler"; import { R } from "#server/utils/response"; import { getAgentBySlug } from "#server/service/agent/agent"; import { agentRowToCard } from "#server/service/a2a/converter"; export default defineWrappedResponseHandler(async (event) => { const agentSlug = getRouterParam(event, "agentSlug"); if (!agentSlug) { return R.error("参数无效", null); } const agent = await getAgentBySlug(agentSlug); if (!agent) { return R.error("agent 不存在", null); } const protocol = event.node.req.headers["x-forwarded-proto"] ?? "http"; const host = event.node.req.headers.host ?? "localhost"; const baseUrl = `${protocol}://${host}`; const card = agentRowToCard(agent, baseUrl); return card; });